﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SDKConsoleTest
{
    class Program
    {
        // http://www.21voa.com/
        // http://www.51voa.com/

        // Development_Report_
        // This_is_America_
        // Agriculture_Report_
        // Science_in_the_News_
        // Health_Report_
        // Explorations_
        // Education_Report_
        // The_Making_of_a_Nation_
        // Economics_Report_
        // American_Mosaic_
        // In_the_News_
        // American_Stories_
        // Words_And_Their_Stories_
        // People_in_America_
        // Science_Report_
        // Environment_Report_

        // American_Cafe_
        // Popular_American_
        // Words_And_Idioms_
        // Intermediate_American_English_

        // such as
        // http://www.21voa.com/VOA_Special_English_2008/Science_in_the_News_5150.html
        // http://www.21voa.com/Voa_Classic_Course/Intermediate_American_English_9014.html
        static void Main(string[] args)
        {
                  
        }

        private void Test2()
        {
        }
        private void Test()
        {
            //test
            List<String> urls = new List<string>();
            Program p = new Program();
            p.GetUrls("http://www.21voa.com/", "VOA_Special_English_", 2006, ref urls);     
        }

        private void GetUrls(String domain, String type, int year, ref List<String> urls)
        {
            List<String> allSubTypes = new List<string>();
            allSubTypes.Add("Development_Report_");
            allSubTypes.Add("This_is_America_");
            allSubTypes.Add("Agriculture_Report_");
            allSubTypes.Add("Science_in_the_News_");
            allSubTypes.Add("Health_Report_");
            allSubTypes.Add("Explorations_");
            allSubTypes.Add("Education_Report_");
            allSubTypes.Add("The_Making_of_a_Nation_");
            allSubTypes.Add("Economics_Report_");
            allSubTypes.Add("American_Mosaic_");
            allSubTypes.Add("In_the_News_");
            allSubTypes.Add("American_Stories_");
            allSubTypes.Add("Words_And_Their_Stories_");
            allSubTypes.Add("People_in_America_");
            allSubTypes.Add("Science_Report_");
            allSubTypes.Add("Intermediate_American_English_");

            foreach (String subType in allSubTypes)
            {
                String url = domain + type + year.ToString() + "/Index_" + subType + "1.html";
                List<String> indexUrls = new List<string>();
                SharpDownloadSDK.HtmlParseUtilities.GetAllAdressesByUrlAndExts(url, ".html", ref indexUrls);

                foreach (String indexUrl in indexUrls)
                {
                    if (indexUrl.IndexOf(subType) == 0)
                    {
                        String listenPageUrl = domain + type + year.ToString() + "/" + indexUrl;
                        SharpDownloadSDK.HtmlParseUtilities.GetAllAdressesByUrlAndExts(listenPageUrl, ".mp3",ref urls);
                    }
                }                
            }
        }
    }
}
